#ifndef INC_SELECTIONMAN_H
#define INC_SELECTIONMAN_H

#include <set>
#include <QObject>

class UMLObject;

class SelectionMan : public QObject
{
	Q_OBJECT;

	public:

		typedef std::set<UMLObject*> ObjSet;
		typedef ObjSet::iterator iterator;
		typedef ObjSet::const_iterator const_iterator;

		/*** SELECTION EDITING ***/

		/**
		 * Clears selection on all objects in the associated diagram.
		 *
		 * Note: only controller objects should call this.
		 */
		void clear();

		/**
		 * Toggles selection of the specified object.
		 *
		 * Note: only controller objects should call this.
		 */
		void toggle(UMLObject* obj);

		bool contains(UMLObject* obj) const;

		bool empty() const;

		iterator begin();
		const_iterator begin() const;

		iterator end();
		const_iterator end() const;

	signals:

		/**
		 * Emitted when the selection is changed. Newsel will contain the
		 * newly-selected object, which is not necessarily the whole selection.
		 * @param newsel the newly-selected object, or NULL if cleared
		 */
		void changed(UMLObject *newsel);

	private:

		ObjSet _selected;
};

inline SelectionMan::const_iterator SelectionMan::begin() const
{
	return _selected.begin();
}

inline SelectionMan::const_iterator SelectionMan::end() const
{
	return _selected.end();
}

#endif // INC_SELECTIONMAN_H

